<!-- loginRelease.html -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>登录</title>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="./css/CFNetPP_Base.css">
    <style type="text/css" media="screen">
        body html {
            height: 100%;
            /*background: url(image/bg_login.png);*/
        }

        .login_div {
            /*background: url(image/bg_login.png);*/
            /*height: 100%;*/
            /* background-size: 100%;*/
        }

        .login_content_div {
            padding: 160px 30px 0 30px;
            /*height: 100%;*/
        }

        .logo_div {
            /*text-align: center;*/
            height: 46px;
            position: absolute;
            top: 80px;
        }

        .logo_img {
            width: 46px;
            height: 46px;
            vertical-align: bottom;
        }

        .logo_title {
            font-size: 30px;
            /*	color: #454545;*/
            color: #fff;
        }

        .input_text {
            width: 100%;
            height: 40px;
            margin-top: 10px;
            border: 1px solid #454545;
        }

        .user_type_select {
            margin-top: 10px;
            width: 100px;
            height: 40px;
            border: 1px solid #454545;
        }

        .login_btn {
            margin-top: 35px;
            color: white;
            font-size: 18px;
            background-color: #fe9901;
            opacity: 0.9;
        }

        .mui-btn-block {
            padding: 6px 0;
        }

        .mui-input-row label {
            width: 14%;
            padding: 8px 0;
            line-height: 1em;
        }

        .mui-input-row label ~ input, .mui-input-row label ~ select, .mui-input-row label ~
        textarea {
            width: 86%;
        }

        .mui-input-row {
            border-bottom: 1px solid #e6e6e6;
            height: 40px;
            margin-top: 30px;
        }

        /*.mui-icon-eye:before{
         color: #fe9901;
         }*/
        .text_input_icon {
            height: 24px;
        }

        .password_about_div {
            padding: 10px 0;
            overflow: auto;
        }

        .left_div {
            float: left;
            width: 50%;
            height: 34px;
        }

        .right_div {
            float: right;
            width: 50%;
            height: 34px;
        }

        .diy_input_row {
            border: none;
            margin: 0;
            height: 34px;
        }

        .mui-checkbox.mui-left label {
            padding: 0;
        }

        .mui-checkbox.mui-left input[type=checkbox], .mui-radio.mui-left input[type=radio] {
            left: 0;
        }

        .mui-checkbox input[type=checkbox]:before, .mui-radio input[type=radio]:before {
            color: #fff;
            font-size: 20px;
        }

        .forget_password_span {
            float: right;
            line-height: 34px;
            color: #fff;
        }

        .mui-checkbox input[type=checkbox]:checked:before, .mui-radio input[type=radio]:checked:before {
            color: #EA9310;
            image: url(image/login_chek.png)
        }

        html, body {
            background-color: white;
            height: 100%;
        }

        .div_btton {
            width: 100%;
            text-align: center;
            position: absolute;
            bottom: 5px;
        }

        .mui-backdrop {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 998;
            background-color: rgba(0, 0, 0, .3);
        }

        #account_input, #password_input {
            line-height: 21px;
            width: 100%;
            height: 40px;
            margin-bottom: 15px;
            padding: 0px 25px;
            padding-top: 0px;
            padding-right: 25px;
            padding-bottom: 0px;
            padding-left: 0px;
            -webkit-user-select: text;
            border-radius: 3px;
            outline: 0;
            /*   background-color:#000000;*/
            background-color: transparent;
            color: #fff;
            border-style: none;
            -webkit-appearance: none;
        }

        ::-webkit-input-placeholder { /* WebKit browsers */
            color: #cdcdcd;
        }

        .login-background-img {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<img src="image/bg_login.png" class="login-background-img"></img>
<div class="login_div" style="z-index:2;">
    <div class="login_content_div">
        <div class="logo_div">
            <img class="logo_img" src="image/new_logo.png" alt="">
            <span class="logo_title"> 长风网 </span>
        </div>
        <div class="mui-input-row">
            <!--<label><img class="text_input_icon" src="image/icon_yonghuming.png" alt=""></label>-->
            <input id="account_input" type="email" class="mui-input-clear" placeholder="请输入用户名">
        </div>
        <div class="mui-input-row mui-password">
            <!--	<label><img class="text_input_icon" src="image/icon_mima.png" alt=""></label>-->
            <input id="password_input" type="password" class="mui-input-clear" placeholder="请输入密码"
                   onkeypress="onKeyClick()">
        </div>
        <button type="button" class="mui-btn mui-btn-warning mui-btn-block login_btn" onclick="loginClick()">
            登录
        </button>
        <div class="password_about_div">
            <!--<div class="left_div">
                <div class="mui-input-row mui-checkbox mui-left diy_input_row">
                    <label class="base_grey base_tag_font" style="width: 60px; margin: 8px 28px;color: #fff;" for="remember_password">记住密码</label>
                    <input id="remember_password" name="checkbox" value="Item 1" type="checkbox" >
                </div>
            </div>-->
            <div id="forget_password" class="right_div base_grey base_tag_font " style="position: relative;">
                <span class="forget_password_span"> <span id="to_regis">注册 | </span><span
                        id="to_forget_password">忘记密码?</span> </span>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="script/api.js"></script>
<script type="text/javascript" src="script/jquery.min.js"></script>
<script type="text/javascript" src="script/mui.min.js"></script>
<script type="text/javascript" src="script/MD5.js"></script>
<script type="text/javascript" src="script/requestTool.js"></script>
<script type="text/javascript" src="script/jpushNotifi.js"></script>
<script type="text/javascript" src="script/push.js"></script>
<script type="text/javascript">
    mui.init();
    var registrationid = '';
    apiready = function () {
        //取消绑定账户
        unbindAccount();
        var oldTags = $api.getStorage('cfnetpptorstags');
        //取消班级标签
        removeTag(oldTags);
        oldTags = $api.getStorage('cfnetppjidtags');
        removeTag(oldTags);
        api.setFullScreen({
            fullScreen: false
        });
        DetermineTheIosStatusBarar();
        setupAccountPWD();
        setupForgetPWD();
        closewin();
    }

    /*ios系统的状态栏*/
    function DetermineTheIosStatusBarar() {
        var systemType = api.systemType;
        if (systemType == 'ios') {
            api.setStatusBarStyle({
                style: 'light'
            });
        }
    }

    function setupForgetPWD() {
        $('#to_forget_password').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'forgetpassword',
                url: 'forgetpassword.html',
                vScrollBarEnabled: false,
                hScrollBarEnabled: false
            });
        });
        $('#to_regis').click(function () {
            api.openWin({
                useWKWebView: true,
                name: 'RegisterController',
                url: 'RegisterController.html',
                vScrollBarEnabled: false,
                hScrollBarEnabled: false
            });
        });
    }

    function loginClick() {
        var account = $('#account_input').val();
        var password = $('#password_input').val();
        if (account.length == 0 || password.length == 0) {
            api.toast({
                msg: '账户名和密码不能为空!',
                duration: 2000,
                location: 'bottom'
            });
            return;
        }
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '正在登录',
            text: '请稍候...',
            modal: true
        });
        var params = {
            name: account,
            password: password
        };
        //            alert(url_login);
        cfnetppPOST(url_login, params, false, function (data, status) {
            api.hideProgress();
//			   alert("添加章节操作"+JSON.stringify(data));
            if (status == 'success') {
                if (data.code == 200) {
                    $api.setStorage('cfnetemail', account);
                    rememberAccountPWD();
                    loginSucceed(data.data.userinfo);
                    $api.setStorage('cfnetppjxid', "");
                    $api.setStorage('cfnetppjid', "");
                    $api.setStorage('tempjid', "");
                    $api.setStorage('cfnetSelectType', "");
                    $api.setStorage('cfnetTrainSelectType', "");
                    //						initJpush();
                    //初始化极光推送
//						//设置密码
//						setupPWD();
                    api.toast({
                        msg: '登录成功'
                    });
                    setTimeout('jumpToNextPage()', 800);
                } else {
                    var errorStatus = parseInt(data.code);

                    var msgString = '';
                    switch (errorStatus) {
                        case 1:
                            msgString = '账号错误';
                            break;
                        case 2:
                            msgString = '密码错误';
                            break;
                        default:
                            msgString = '登录失败';
                    }
                    api.toast({
                        msg: msgString
                    });
                }
            } else {
                api.toast({
                    msg: '网络异常!'
                });
            }
        });
    }

    function loginSucceed(data) {
        $api.setStorage('cfnetppuid', data.uid);
        //		$api.setStorage('cfnetppjid', data.jid);
        //		$api.setStorage('cfnetppjxid', data.jxid);
        $api.setStorage('cfnetppusername', data.uname);
        $api.setStorage('cfnetpprealname', data.uname);
        //		var opentype = data.opentype;
        //		if (opentype == 'null') {
        //			opentype == 1;
        //		}
        $api.setStorage('cfnetppopentype', 2);
        //打开0周报,1日报,2日报周报都有
        //todo
        var userprofile = data.pic;
        $api.setStorage('cfnetppusericon', userprofile);
        //记录登陆状态
        $api.setStorage('cfnetppLoginStatus', 1);
        api.sendEvent({//发送登陆成功通知
            name: 'loginSucceedNotifi'
        });
    }

    //发送用户完善信息通知
    function sendUserInfoNotifi() {
        cfnetppPOST(urlUserinfoNotifi, {
            uid: $api.getStorage('cfnetppuid')
        }, false, function (data, status) {
        });
    }

    //判断用户类型
    function saveUserType(data) {
        var usertype = data.usertype;
        $api.setStorage('userType', usertype);
    }

    function jumpToNextPage() {
        //var usertype = $api.getStorage('userType');
        //alert(usertype);
        api.openWin({
            useWKWebView: true,
            name: 'index',
            url: 'index.html',
            slidBackEnabled: false,
            animation: {
                type: "none",                //动画类型（详见动画类型常量）
                subType: "from_right",       //动画子类型（详见动画子类型常量）
                duration: 300                //动画过渡时间，默认300毫秒
            },
            hScrollBarEnabled: false,
            vScrollBarEnabled: false
        });
    }

    function setupAccountPWD() {
        //设置账号
        $('#account_input').val($api.getStorage('cfnetppaccount'));
        //设置密码
        setupPWD();
    }

    function setupPWD() {
        $('#password_input').val($api.getStorage('cfnetpppassword'));
//			//设置密码
//			var remPWDStatus = $api.getStorage('remPWDStatus');
//			if (remPWDStatus == 'true') {
//				$('#remember_password').attr('checked', 'true');
//				$('#password_input').val($api.getStorage('cfnetpppassword'));
//			} else {
//				$('#password_input').val('');
//			}
    }

    function rememberAccountPWD() {
        //记录账号
        $api.setStorage('cfnetppaccount', $('#account_input').val());
        $api.setStorage('cfnetpppassword', $('#password_input').val());
//			//记录密码
//			var remPWDStatus = $('#remember_password').is(':checked');
//			if (remPWDStatus == true) {
//				
//				$api.setStorage('remPWDStatus', 'true');
//			} else {
//				$api.setStorage('remPWDStatus', 'false');
//			}
    }

    function onKeyClick() {
        if (event.keyCode == 13) {
            loginClick();
        }
    }

    function closewin() {
        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            api.closeWidget({
                id: 'A6947555569146',
                retData: {
                    name: 'closeWidget'
                },
                animation: {
                    type: 'flip',
                    subType: 'form_bottom',
                    duration: 500
                },
                silent: true
            });
        });
    }
</script>
</html>